<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style>
        #tip {
            background-color: #ddf;
            color: #333;
            border: 1px solid silver;
            box-shadow: 3px 4px 3px 0px silver;
            position: absolute;
            top: 30px;
            right: 10px;
            border-radius: 5px;
            overflow: hidden;
            line-height: 20px;
        }
        #tip input[type="text"] {
            height: 25px;
            border: 0;
            padding-left: 5px;
            width: 280px;
            border-radius: 3px;
            outline: none;
        }
    </style>
</head>
<body>
<div style="margin-bottom: 10px;font-size: 12px;color:#999999;">
    (按住鼠标左键拖动地图、鼠标滚轮滚动缩放地图，找到正确的位置点击一下即可)
</div>
<div id="mapContainer" style="width:600px;height:400px"></div>
<div id="tip">
    <input type="text" id="keyword" name="keyword" value="请输入关键字：(选定后搜索)" onfocus='this.value=""'/>
</div>

<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=dbf1281241fe7a7a9c04b486e1a31651"></script>


<script language="javascript">


    var windowsArr = [];
    var marker = [];
    var mapObj = new AMap.Map("mapContainer", {
        resizeEnable: true,
        center: [116.3,39.9],//地图中心点
        zoom: 13,//地图显示的缩放级别
        keyboardEnable: false
    });

    mapObj.on('click', function(e) {
        //alert('您在[ '+e.lnglat.getLng()+','+e.lnglat.getLat()+' ]的位置点击了地图！');

        //获取父窗口的函数并关闭窗口
        self.parent.insertGps(e.lnglat.getLng()+","+e.lnglat.getLat());
        javascript:parent.jQuery.fancybox.close();

    });



    AMap.plugin(['AMap.Autocomplete','AMap.PlaceSearch'],function(){
        var autoOptions = {
            city: "北京", //城市，默认全国
            input: "keyword"//使用联想输入的input的id
        };
        autocomplete= new AMap.Autocomplete(autoOptions);
        var placeSearch = new AMap.PlaceSearch({
            city:'北京',
            map:mapObj
        })
        AMap.event.addListener(autocomplete, "select", function(e){
            //TODO 针对选中的poi实现自己的功能
            placeSearch.search(e.poi.name)
        });
    });




</script>
</body>
</html>